import React from 'react';

class App extends React.Component {
  constructor() {
    super();
    this.state = {
      list: [0, 1, 2],
      count: 0,
    }
  }

  shouldComponentUpdate(nextProps, nextState, nextContext) {
    if (this.state.list !== nextState.list) {
      return true;
    }
    return false;
  }

  handle = (e) => {
    const {list} = this.state;
    list.push(4);
    this.setState({list: [...list]});
  }

  render() {
    console.log(this.state.count)
    return (
      <div>
        <button onClick={this.handle}>点我</button>
        <span>{this.state.list.map((value) => value)}</span>
      </div>
    );
  }
}

export default App;
